class Solution(object):
    def asteroidCollision(self, asteroids):
        """
        :type asteroids: List[int]
        :rtype: List[int]
        """
        st = []
        for ast in asteroids:
            while ast < 0 and st and st[-1] > 0:
                node = st.pop()
                if abs(ast) <= node:
                    if abs(ast) == node:
                        ast = 0
                    else:
                        ast = node
                    break
            if ast:
                st.append(ast)

        return st

data = Solution()
asteroids = [5, 10, -5]
print(data.asteroidCollision(asteroids))
